import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.webkit.ValueCallback;
import android.webkit.WebView;
import android.widget.Toast;

import java.util.List;

import libs.yzx.zaza.R;

/**
 * Created by Administrator on 2016/8/1
 */
public class ActionBarActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_ab);

        FragmentManager fm = getSupportFragmentManager();
        List<Fragment> list = fm.getFragments();


        android.app.FragmentManager fm2 = getFragmentManager();
        for (int i = 0; i < fm2.getBackStackEntryCount(); i++) {
            android.app.FragmentManager.BackStackEntry bse = fm2.getBackStackEntryAt(i);

            WebView v = new WebView(this);
            /* android 4.4以上调用有返回值的js */
            if(Build.VERSION.SDK_INT >= 19)
                v.evaluateJavascript("javascript:getStr()", new ValueCallback<String>() {
                    public void onReceiveValue(String value) {
                        Toast.makeText(ActionBarActivity.this, value, Toast.LENGTH_SHORT).show();
                    }
                });

        }


        new ServiceConnection() {
            @Override
            public void onServiceConnected(ComponentName name, final IBinder service) {
                service.isBinderAlive();
                service.pingBinder();
                try {

                    service.linkToDeath(new IBinder.DeathRecipient() {
                        @Override
                        public void binderDied() {
                            service.unlinkToDeath(this, IBinder.FLAG_ONEWAY);
                        }
                    }, 0);
                } catch (Exception e) {
                    //hehehehe
                    // 付武器from
                }
            }

            @Override
            public void onServiceDisconnected(ComponentName name) {

            }

        };

        new IBinder.DeathRecipient() {
            @Override
            public void binderDied() {

            }
        };

    }

}
